// const QQMapWX = require('/utils/qqmap-wx-jssdk.min.js');
App({
  onLaunch: function () {
    // this.globalData.qqmapsdk = new QQMapWX({
    //   key: this.globalData.mapKey
    // });


    // 获取系统状态栏信息
    wx.getSystemInfo({
      success: e => {
        this.globalData.windowWidth = e.windowWidth;
        this.globalData.rpxToPxBl = e.windowWidth / 750;
        this.globalData.StatusBar = e.statusBarHeight;
        let custom = wx.getMenuButtonBoundingClientRect();
        this.globalData.Custom = custom;
        this.globalData.CustomBar = e.windowHeight < 400 ? 32 : 44;
      }
    })
  },
downloadFile(url) {
    return new Promise((resolve, reject) => {
      wx.downloadFile({
        url: url,
        success(res) {
          if (res.statusCode === 200) {
            resolve(res)
          } else {
            reject(res)
          }
        },
        fail(res) {
          reject(res)
        }
      })
    });
  },
  wxLogin: function () {
    let that = this;
    // 登录
    return new Promise(function (success, fail) {
      wx.login({
        success: res => {
          if (res.code) {
            success(res.code)
          } else {
            fail("获取Code失败")
          }
        }
      })
    }).then(code => {
      let that = this;
      let companyId = that.globalData.companyId;
      let platformId = that.globalData.platformId;
      return api.checkLogin(code, companyId, platformId);
    })
  },
  //返回首页
  backHome: function () {
    let pages = getCurrentPages();
    wx.navigateBack({
      delta: pages.length - 1,
    })
  },
  showLoading() {
    wx.showLoading({
      title: '请稍后',
    })
  },

  // 金额显示(千位逗号隔开,显示两位小数)
  moneyMeter:function(num){
    return num.toFixed(2).replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
  },
  // 提示框
  showToast: function (str) {
    if (typeof str != "string") return;
    wx.showToast({
      title: str, // 内容
      icon: 'none',
      duration: 2000,
    });
  },
  globalData: {
    userBean: '',
    token: '',
    loginDone:false,
    rpxToPxBl: 0.5,
    windowWidth: 350,
    StatusBar: 0,
    CustomBar: 0,
    qqmapsdk: undefined,
    addressName: "",
    cityName: "",
    lat: 0,
    lng: 0,
    defaultAvatarUrl:'',
    dataArr: [
            { minPrice: 10, maxPrice: 22 },
            { minPrice: 2.1, maxPrice: 10 },
            { minPrice: 5.50, maxPrice: 12.1 },
            { minPrice: 99.6, maxPrice: 10 },
            { minPrice: 36, maxPrice: 40 },
            { minPrice: 4.01, maxPrice: 21 },
            { minPrice: 9.55, maxPrice: 10 },
            { minPrice: 65, maxPrice: 70 }
        ],
    companyId: '3171776001692663893', //租户ID
    platformId: '3189609977215975481', //平台ID
  },

})
